package com.tony.spring.mode.prototype;

import com.tony.spring.mode.singleton.DemoService;

/**
 * 原型模式
 * @author Tony
 *
 */
public class PrototypeMode implements Cloneable{
	
//	private ProtypeMode protypeMode = new ProtypeMode();
	
	private int name;
	
	private String username;
	private DemoService demoService; 
	
	/**
	 * 一种对象在创建过程，非常耗时同时耗资源，而且考虑多个实例使用情况
	 * 数据库连接池，多个实例（new对象？）Map 存储本质
	 * 优化的本质-将流程简单化，节约时间，就叫优化-技术术语增加了沟通的成本
	 */
	/**
	 * 
	 * @return
	 * @throws CloneNotSupportedException 
	 */
	public PrototypeMode getProtype() throws CloneNotSupportedException{
		return (PrototypeMode) super.clone();
	}
	
	public static void main(String[] args) throws CloneNotSupportedException {
		PrototypeMode mode = new PrototypeMode();
		PrototypeMode mode2 = mode.getProtype();
		
		System.out.println(mode.hashCode());
		System.out.println(mode2.hashCode());
	}

}
